package com.zw.stock_sell_storage.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zw.stock_sell_storage.dto.InventoryDto;
import com.zw.stock_sell_storage.dto.MyPageDto;
import com.zw.stock_sell_storage.dto.ex.InventoryDtoEx;
import com.zw.stock_sell_storage.service.IInventoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/inventory")
public class InventoryController {
    @Autowired
    IInventoryService iInventoryService;

    @RequestMapping("/queryInventoryByGoodsCode")
    public InventoryDto queryInventoryByGoodsCode(String goodsCode){
        return iInventoryService.queryInventoryByGoodsCode(goodsCode);
    }

    @RequestMapping("/addInventory")
    public boolean addInventory(@RequestBody InventoryDto inventoryDto){
        return iInventoryService.addInventory(inventoryDto);
    }

    @RequestMapping("/updateInventory")
    public boolean updateInventory(@RequestBody InventoryDto inventoryDto){
        return iInventoryService.updateInventory(inventoryDto);
    }

    @RequestMapping("/queryInventoryList")
    public Page<InventoryDto> queryInventoryList(@RequestBody MyPageDto<InventoryDtoEx> myPageDto){
        return iInventoryService.queryInventoryList(myPageDto);
    }

    @RequestMapping("/queryInventoryById")
    public InventoryDto queryInventoryById(int goodsId){
        return iInventoryService.queryInventoryById(goodsId);
    }
}
